package net.pimpas.communication.serviceprovider;

import java.util.List;

import net.pimpas.communication.channel.Channel;
import net.pimpas.communication.exception.ChannelException;
import net.pimpas.communication.listener.ChannelListener;
import net.pimpas.communication.message.Message;
import net.pimpas.core.serviceprovider.ServiceProvider;
import net.pimpas.executor.serviceprovider.ExecutorServiceProvider;

public interface CommunicationServiceProvider extends ServiceProvider {
	
	Channel createChannel( String channelID, boolean forceCreate ) throws ChannelException;
	Channel createChannel( String channelID, boolean forceCreate, ExecutorServiceProvider executor )
		throws ChannelException;
	Channel getChannel( String channelID ) throws ChannelException;
	
	void closeChannel( String channelID ) throws ChannelException;
	void closeChannel( Channel channel ) throws ChannelException;
	
	void subscribe( String channelID, ChannelListener listener ) throws ChannelException;
	void subscribe( Channel channel, ChannelListener listener ) throws ChannelException;
	
	List<Message> unsubscribe( String channelID, ChannelListener listener ) throws ChannelException;
	List<Message> unsubscribe( Channel channel, ChannelListener listener ) throws ChannelException;
	
}